const express = require("express");
const router = express.Router();
const conf = require("../mod/config");
const request = require("../mod/request");

router.get('/', function(req, res, next) {
  request.send({
    path: "/GetCultureNews?category=645&pageIndex=1&pageSize=10",
    callback: (data) => {
      res.render("custom_index", {
        conf: conf,
        news: data.hasValue == "true" && data.data || {},
        name: "custom"
      });
    },
    error: (err) => {
      res.render("404", {
        conf: conf
      });
    },
    clientReq: req
  });
});
router.get('/p:id', function(req, res, next) {
  var id = req.params.id;
  request.send({
    path: "/GetNewsDetail/" + id,
    callback: (data) => {
      res.render("local_details", {
        conf: conf,
        name:"custom",
        detail: data.hasValue == "true" && data.data || {}
      });
    },
    error: (err) => {
      res.render("404", {
        conf: conf
      });
    },
    clientReq: req
  });
});

module.exports = router;